home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / sprite.X11R3 / hdr / cg2reg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-03  |  10.1 KB  |  314 lines

  1. /* @(#)cg2reg.h 1.11 88/02/08 SMI */
  2.  
  3. /*
  4.  * Copyright 1983, 1987 by Sun Microsystems, Inc.
  5.  */
  6.  
  7. #ifndef    cg2reg_DEFINED
  8. #define    cg2reg_DEFINED
  9.  
  10. /*
  11.  * cg2 -- color frame buffers with rasterop chips
  12.  *
  13.  * The frame buffer address space looks like this:
  14.  *
  15.  * 0x000000    plane mode memory
  16.  * 0x100000    pixel mode memory
  17.  * 0x200000    rop mode memory
  18.  * 0x300000    control registers
  19.  * 0x310000    color map
  20.  *
  21.  * To save on virtual address space, we don't map the plane or pixel mode
  22.  * memory (first two megabytes).  However, when calling mmap the user has
  23.  * to add 2M to the desired offset anyway (goofy, huh?).
  24.  *
  25.  * The board can also be jumpered so the plane and pixel mode memory are
  26.  * not accessible at all, and the rop mode memory and control registers
  27.  * are decoded starting at address offset 0.
  28.  */
  29.  
  30. /* offset to and size of mapped part of frame buffer */
  31. #define    CG2_MAPPED_OFFSET    (sizeof (struct cg2memfb))
  32. #define    CG2_MAPPED_SIZE        (sizeof (struct cg2fb))
  33.  
  34. /* interrupt priority */
  35. #define    CG2_INT_PRI    4
  36.  
  37. /* frame buffer resolution constants */
  38. #define CG2_WIDTH    1152
  39. #define CG2_HEIGHT    900
  40. #define CG2_SQUARE    1024
  41. #define CG2_DEPTH    8
  42.  
  43. /* 
  44.  * Structure describing plane and pixel mode memory -- pretty useless
  45.  * since we don't map that part of the frame buffer.
  46.  */
  47. struct    cg2memfb {
  48.     union bitplane {            /* word mode memory */
  49.         short word[CG2_HEIGHT][CG2_WIDTH/(8*sizeof(short))];
  50.         short sword[CG2_SQUARE][CG2_SQUARE/(8*sizeof(short))];
  51.     } memplane[8];
  52.     union byteplane {            /* pixel mode memory */
  53.         u_char pixel[CG2_HEIGHT][CG2_WIDTH];
  54.         u_char spixel[CG2_SQUARE][CG2_SQUARE];
  55.     } pixplane;
  56. };
  57.  
  58. /* control/status register */
  59. struct cg2statusreg {
  60.     u_int unused : 2;    /* reserved for future use */
  61.     u_int fastread : 1;    /* has fast read feature */
  62.     u_int id : 1;        /* has ID, extended status registers */
  63.     u_int resolution : 4;    /* screen resolution */
  64. #define    CG2_SCR_1152X900    0
  65. #define    CG2_SCR_1024X1024    1
  66. #define    CG2_SCR_1600X1280    2
  67. #define    CG2_SCR_1440X1440    3
  68.     unsigned retrace : 1;    /* rdonly: monitor in retrace */
  69.     unsigned inpend  : 1;    /* rdonly: interrupt pending */
  70.     unsigned ropmode : 3;    /* Rasterop mode */
  71.     unsigned inten   : 1;    /* enab interrupt at end of retrace */
  72.     unsigned update_cmap : 1;
  73.             /* copy TTL cmap to ECL cmap next vert retrace*/
  74.             /* silently disables writing to TTL cmap */
  75.     unsigned video_enab  : 1;    /* enab video DACs */
  76. };
  77.  
  78. /* extended status register */
  79. struct cg2_status2 {
  80.     u_int gpintreq : 1;    /* GP interrupt request */
  81.     u_int gpintdis : 1;    /* GP interrupt disable */
  82.     u_int unused : 13;    /* reserved for future use */
  83.     u_int gpbus : 1;    /* GP bus enabled (read only) */
  84. };
  85.  
  86. /* double buffering control register */
  87. struct dblbufreg {
  88.     u_int display_b : 1;    /* Display memory set B or A. */
  89.             /* Synchronized to start of vertical retrace. */
  90.     u_int read_b : 1;    /* Read memory set B or A. */
  91.     u_int nowrite_b : 1;    /* Do not update memory set B on writes. */
  92.     u_int nowrite_a : 1;    /* Do not update memory set A on writes. */
  93.     u_int read_ecmap : 1;/* ECL to TTL cmap transfer direction. */
  94.             /* Synchronized to start of Vertical retrace. */
  95.     u_int fast_read : 1; /* Return invalid data but fast Dtack on read */
  96.     u_int wait : 1;    /* Write a '1' to set.  Bit will remain */
  97.             /* high until a full vertical retrace period has */
  98.             /* elapsed.  The bit clears itself. */
  99.     u_int update_ecmap : 1;
  100.     u_int reserved : 8;
  101. };
  102.  
  103. /* zoom/pan registers; Sun-2 color board only */
  104. struct cg2_zoom {
  105.     union {                /*----- word pan register */
  106.         unsigned short reg;        /* hi 16 of 20 bit pix addr */
  107.                         /* pix addr = CG2_WIDTH*y+x */
  108.         char pad[4096];
  109.     } wordpan;
  110.     union {                /*----- zoom and line offset register */
  111.         struct {
  112.             unsigned unused  : 8;
  113.             unsigned lineoff : 4;    /* y offset into zoomed pixel */
  114.             unsigned pixzoom : 4;    /* zoomed pixel size - 1 */
  115.         } reg;
  116.         short word;
  117.         char pad[4096];
  118.     } zoom;
  119.     union {                /*----- pixel pan register */
  120.         struct {
  121.             unsigned unused   : 8;
  122.             unsigned lorigin  : 4;    /* lo 4 bits of pix addr   */
  123.             unsigned pixeloff : 4;    /* zoomed pixel x offset/4 */
  124.         } reg;
  125.         short word;
  126.         char pad[4096];
  127.     } pixpan;
  128.     union {                /*----- variable zoom register */
  129.                         /* reset zoom after line no */
  130.         unsigned short reg;        /* line number 0..1024/4  */
  131.         char pad[4096];
  132.     } varzoom;
  133. };
  134.  
  135. /* misc. control registers; Sun-3 color board etc. */
  136. struct cg2_nozoom {
  137.     union {                /*----- double buffering register */
  138.         struct dblbufreg reg;
  139.         short word;
  140.         char pad[4096];
  141.     } dblbuf;
  142.     union {                /*----- dma window origin register */
  143.         unsigned short reg;
  144.         char pad [4096];
  145.     } dmabase;
  146.     union {                /*----- dma window width register */
  147.         unsigned short reg;        /* reg * 16 specifies width */
  148.         char pad [4096];        /* of dma window.  8 bit. */
  149.     } dmawidth;
  150.     union {                /*----- frame count register */
  151.         unsigned short reg;        /* 8 bit. Read-only. */
  152.             /* Returns frame number mod 256. */
  153.         char pad[4096];
  154.     } framecnt;
  155. };
  156.  
  157. /* structure describing mapped part of frame buffer */
  158. struct cg2fb {
  159.     union {                    /* ROP mode memory */
  160.         union bitplane ropplane[8];    /* word mode memory with ROP */
  161.         union byteplane roppixel;    /* pixel mode memory with ROP */
  162.     } ropio;
  163.     union {                    /* rasterop unit control */
  164.         struct memropc ropregs;        /* normal register access */
  165.         struct {
  166.             char pad[2048];        /* for pixmode src reg prime */
  167.             struct memropc ropregs;    /* byte xfer loads alternate */
  168.         } prime;            /* src register bits */
  169.         char pad[4096];
  170.     } ropcontrol[9];
  171.     union {                /*----- status register */
  172.         struct cg2statusreg reg;
  173.         short word;
  174.         char pad[4096];
  175.     } status;
  176.     union {                /*----- per plane mask register */
  177.         unsigned short reg;        /* 8 bits 1bit -> wr to plane*/
  178.         char pad[4096];
  179.     } ppmask;
  180.     union {
  181.         struct cg2_zoom zoom;
  182.         struct cg2_nozoom nozoom;
  183.     } misc;
  184.     union {                /*----- interrupt vector register */
  185.         unsigned short reg;        /* line number 0..1024/4  */
  186.         char pad[32];
  187.     } intrptvec;
  188.     union {                /* board ID */
  189.         u_short reg;
  190.         char pad[16];
  191.     } id;
  192.     union {                /* extended status */
  193.         struct cg2_status2 reg;
  194.         u_short word;
  195.         char pad[16];
  196.     } status2;
  197.     union {                /* auxiliary ropmode register */
  198.         u_short reg;
  199.         char pad[4032];
  200.     } ropmode;
  201.     u_short redmap[256];            /* shadow color maps */
  202.     u_short greenmap[256];
  203.     u_short bluemap[256];
  204. };
  205.  
  206. /*
  207.  *    ROPMODE            PARALLEL         LD_DST  LD_SRC   Description
  208.  *                           ON      ON        */
  209. #define    PRWWRD    0    /* parallel 8 plane,  read    write,    wrdmode */
  210. #define    SRWPIX    1    /* single     pixel,  read    write,     pixmode */
  211. #define    PWWWRD    2    /* parallel 8 plane,  write   write,    wrdmode */
  212. #define    SWWPIX    3    /* single     pixel,  write   write,    pixmode */
  213. #define    PRRWRD    4    /* parallel 8 plane,  read    read,    wrdmode */
  214. #define    PRWPIX    5    /* parallel16 pixel,  read    write,    pixmode */
  215. #define    PWRWRD    6    /* parallel 8 plane,  write   read,    wrdmode */
  216. #define    PWWPIX    7    /* parallel16 pixel,  write   write,    pixmode */
  217.  
  218. /*
  219.  * ROP control unit numbers
  220.  */
  221. #define CG2_ROP0    0    /* rasterop unit for bit plane 0 */
  222. #define CG2_ROP1    1    /* rasterop unit for bit plane 1 */
  223. #define CG2_ROP2    2
  224. #define CG2_ROP3    3
  225. #define CG2_ROP4    4
  226. #define CG2_ROP5    5
  227. #define CG2_ROP6    6
  228. #define CG2_ROP7    7
  229. #define CG2_ALLROP    8    /* writes to all units enabled by PPMASK */
  230.                 /* reads from plane zero */
  231.                 
  232. #define    CG_SRC        0xCC
  233. #define    CG_DEST        0xAA
  234. #define    CG_MASK        0xf0
  235. #define    CG_NOTMASK    0x0f
  236. #define    CGOP_NEEDS_MASK(op)        ( (((op)>>4)^(op)) & CG_NOTMASK)
  237.  
  238. /*
  239.  *----------- Defines for accessing the rasterop units
  240.  */
  241. #define    cg2_setrsource(fb, ropunit, val)                \
  242.         ((fb)->ropcontrol[(ropunit)].ropregs.mrc_source1 = (val))
  243. #define    cg2_setrsource_pix(fb, ropunit, val) \
  244.         ((fb)->ropcontrol[(ropunit)].prime.ropregs.mrc_source1 = (val))
  245. #define    cg2_setlsource(fb, ropunit, val)                \
  246.         ((fb)->ropcontrol[(ropunit)].ropregs.mrc_source2 = (val))
  247. #define    cg2_setlsource_pix(fb, ropunit, val) \
  248.         ((fb)->ropcontrol[(ropunit)].prime.ropregs.mrc_source2 = (val))
  249. #define    cg2_setpattern(fb, ropunit, val)                \
  250.         ((fb)->ropcontrol[(ropunit)].ropregs.mrc_pattern = (val))
  251. #define    cg2_setlmask(fb, ropunit, val) \
  252.         ((fb)->ropcontrol[(ropunit)].ropregs.mrc_mask1 = (val))
  253. #define    cg2_setrmask(fb, ropunit, val) \
  254.         ((fb)->ropcontrol[(ropunit)].ropregs.mrc_mask2 = (val))
  255. #define    cg2_setshift(fb, ropunit, shft, dir)                \
  256.         ((fb)->ropcontrol[(ropunit)].ropregs.mrc_shift =    \
  257.          (shft)|((dir)<<8)    )
  258. #define    cg2_setfunction(fb, ropunit, val)                \
  259.         ((fb)->ropcontrol[(ropunit)].ropregs.mrc_op = (val))
  260. #define    cg2_setwidth(fb, ropunit, w, count)                \
  261.         ((fb)->ropcontrol[(ropunit)].ropregs.mrc_width = (w));    \
  262.         ((fb)->ropcontrol[(ropunit)].ropregs.mrc_opcount = (count))
  263.  
  264. /*
  265.  *----------- Defines for accessing the zoom and pan registers
  266.  */
  267. #define    cg2_setzoom(fb, pixsize)                    \
  268.         ((fb)->misc.zoom.zoom.reg.pixzoom = (pixsize)-1)
  269. #define    cg2_setpanoffset(fb, xoff, yoff)                \
  270.         ((fb)->misc.zoom.pixpan.reg.pixeloff = (xoff)>>2; \
  271.          (fb)->misc.zoom.zoom.reg.lineoff = (yoff))
  272. #define    cg2_setpanorigin(fb, x, y)                    \
  273.         ((y) = ((fb)->misc.zoom.status.reg.resolution == 1) ? \
  274.             (y)*CG2_SQUARE+(x) : (y)*CG2_WIDTH+(x); \
  275.          (fb)->misc.zoom.pixpan.reg.lorigin = (y)&0xf; \
  276.          (fb)->misc.zoom.wordpan.reg = (y)>>4)
  277. #define    cg2_setzoomstop(fb, y) \
  278.         ((fb)->misc.zoom.varzoom.reg = (y)>>2)
  279.  
  280. /*
  281.  *      Defines that facilitate addressing the frame buffer
  282.  */
  283.  
  284. #define    cg2_pixaddr(fb, x, y)                        \
  285.         (((fb)->status.reg.resolution) ?            \
  286.             &(fb)->pixplane.spixel[(y)][(x)] :        \
  287.             &(fb)->pixplane.pixel[(y)][(x)] )
  288. #define    cg2_wordaddr(fb, plane, x, y)                    \
  289.         (((fb)->status.reg.resolution) ?            \
  290.             &(fb)->memplane[(plane)].sword[(y)][(x)>>4] :    \
  291.             &(fb)->memplane[(plane)].word[(y)][(x)>>4])
  292. #define    cg2_roppixaddr(fb, x, y)                    \
  293.         (((fb)->status.reg.resolution) ?            \
  294.             &(fb)->ropio.roppixel.spixel[(y)][(x)] :    \
  295.             &(fb)->ropio.roppixel.pixel[(y)][(x)])
  296. #define    cg2_ropwordaddr(fb, plane, x, y)                \
  297.         (((fb)->status.reg.resolution) ?            \
  298.             &(fb)->ropio.ropplane[(plane)].sword[(y)][(x)>>4]:\
  299.             &(fb)->ropio.ropplane[(plane)].word[(y)][(x)>>4])
  300. #define    cg2_width(fb )                            \
  301.         ( ((fb)->status.reg.resolution)    ? CG2_SQUARE : CG2_WIDTH )
  302. #define    cg2_height(fb )                            \
  303.         ( ((fb)->status.reg.resolution)    ? CG2_SQUARE : CG2_HEIGHT )
  304. #define    cg2_linebytes(fb, mode)                        \
  305.         ( ((fb)->status.reg.resolution)                \
  306.             ? ( ((mode)&1)?CG2_SQUARE:CG2_SQUARE/8 )    \
  307.             : ( ((mode)&1)?CG2_WIDTH:CG2_WIDTH/8   ))
  308.  
  309. #define    cg2_prskew(x)    ((x) & 15)
  310.  
  311. #define    cg2_touch(a)    ((a)=0)
  312.  
  313. #endif    cg2reg_DEFINED
  314.